<?php
include('includes/functions.php');
$v = new vcalendar();
$v->setConfig(md5('gwstudentassociation.com'), 'gwstudentassociation.com' );
$v->setProperty( 'method', 'PUBLISH' );
$v->setProperty( "X-WR-CALNAME", "Campus Calendar | The GW Student Association" );
$v->setProperty( "X-WR-CALDESC", "Your source for events on campus" );
$v->setProperty( "X-WR-TIMEZONE", "America/New York" );

foreach (get_all_events() as $event) {
	$vevent = new vevent();
	
	if ($event['allday']) {
		$startdate = str_replace("-","",$event['startdate']);
		$enddate = str_replace("-","",$event['enddate']);
		$vevent->setProperty( 'dtstart', $startdate, array('VALUE' => 'DATE'));
		$vevent->setProperty( 'dtend', $enddate, array('VALUE' => 'DATE'));
	} else {
		$start = explode_date($event['startdate'])+explode_time_24($event['starttime']);
		$end = explode_date($event['enddate'])+explode_time_24($event['enddate']);
		$vevent->setProperty( 'dtstart', $start );
		$vevent->setProperty( 'dtend', $end );
	}
	
	//$vevent->setProperty( 'LOCATION', 'Central Placa' );
	$vevent->setProperty( 'summary', $event['title'] );
	if (strlen($event['desc']) > 1) $vevent->setProperty( 'description', $event['desc'] );
	$v->setComponent ( $vevent );

}

$v->returnCalendar();
?>